package system.student.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import system.student.annotate.LogRecord;
import system.student.entity.Course;
import system.student.entity.Score;
import system.student.entity.StudentCourseDetail;
import system.student.entity.StudentDetail;
import system.student.entity.user.Student;

import java.util.List;

public interface StudentMapper {


    @LogRecord(
        module = "注册",
        operation = "学生用户注册",
        operatorType = "用户注册"
    )
    void register(Student student);

    Student selectByUserId();


    @LogRecord(
        module = "选课",
        operation = "学生选课",
        operatorType = "选课"
    )
    int choseCourse(@Param("courseId") Long courseId, @Param("studentId") Long studentId,  @Param("studentName") String studentName);


    @LogRecord(
        module = "登录",
        operation = "学生用户登录",
        operatorType = "用户登录"
    )
    Student selectByUserId(Long id);

    List<Course> selectAllCourse();

    @Select("select * from score where student_id=#{studentId} and course_id=#{courseId}")
    Score findByUserIdAndCourseId(@Param("studentId")Long studentId,@Param("courseId") Long courseId);

    List<StudentCourseDetail> findAllCourseByStudentId(Long id);

    String findById(Long courseId );

    Integer findScoreByCourseName(@Param("courseName")String courseName, @Param("studentId") Long studentId);

    @LogRecord(
        module = "退选",
        operation = "学生退选课程",
        operatorType = "退选"
    )
    void concelCourse(@Param("courseId")Long courseId, @Param("studentId")Long studentId);

    List<StudentDetail> selectStudents();

    void updateUseStateById(@Param("studentId") Long studentId,@Param("state") Integer state);

    void updateClassIdById(@Param("studentId") Long studentId,@Param("classId") Long classId);
}
